<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>修改快递员</span>
			</div>
			<div class="content">
				<table>	
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input  id="check_phone" class="input inline-input" placeholder="请输入手机号码"> <span class="btn btn-info" id="find">立即查找</span></td>
					</tr>
				</table>
			</div>
			
			
			<div class="header">
				<span>查找信息如下</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">姓名</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input  id="check_update_phone" class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">身份证号码</td><td class="content_right"><input id="check_idcard" class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">密码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="update">立即修改</span> <span class="btn">重置</span> </td>
					</tr>
				</table>
			</div>
		</div>
	</body>
	<script src="/qrcode/jquery2.1.4.js"></script>
	<script src="/layer/layer.js"></script>
<script>

	//检验时候的效果
	$("#check_update_phone").mouseenter(function () {
		$("#check_update_phone").css({"background": "rgba(234,97,97,0)"})
	})
	$("#check_phone").mouseenter(function () {
		$("#check_phone").css({"background": "rgba(234,97,97,0)"})
	})

	$("#check_idcard").mouseenter(function () {
		$("#check_idcard").css({"background": "rgba(234,97,97,0)"})
	});




	//隐藏第二个。header content
	$(".header:eq(1),.content:eq(1)").hide();

	//校验手机号
	$("#find").mouseenter(function () {

		var Phone = $("input:eq(0)").val();

		if (Phone.match(/^[0-9_]{11}$/) == null) {

			layer.msg("输入错误，请输入正确的手机号");
			$("#check_phone").css({"background": "rgba(234,97,97,0.3)"})
			return false;

		}
		return true;
	})




	//查找id
	var courierID = null;
	$(function () {
		$("#find").click(function () {
			var windowID = layer.load();
			var c_phone = $("input:eq(0)").val();
			$.getJSON("/courier/find.do", {c_phone: c_phone}, function (data) {
				layer.close(windowID);
				layer.msg(data.result);
				if (data.status == 0) {
					$(".header:eq(1),.content:eq(1)").fadeIn(1000);
					courierID = data.data.c_id;
					$("input:eq(1)").val(data.data.c_name);
					$("input:eq(2)").val(data.data.c_phone);
					$("input:eq(3)").val(data.data.c_password);
					$("input:eq(4)").val(data.data.c_password);

				}
			});
		});

		//校验手机号
		$("#check_update_phone").mouseout(function () {

			var userPhone = $("input:eq(2)").val();

			if (userPhone.match(/^[0-9_]{11}$/) == null) {
				$("#check_update_phone").css({"background": "rgba(234,97,97,0.3)"})
				alert("输入错误，请输入正确的手机号");

				return false;

			}
			return true
		})
		$("#check_idcard").mouseleave(function () {
			var IDCard = $("input:eq(3)").val();
			if (IDCard.match(/^[0-9A-Za-z_]{18}$/) == null) {

				layer.msg("输入错误，请输入正确的身份证号");
				$("#check_idcard").css({"background": "rgba(234,97,97,0.3)"});
				return false;
			}
			return true;
		})


		$("#update").click(function () {
			var windowId = layer.load();
			var c_name = $("input:eq(1)").val();
			var c_phone = $("input:eq(2)").val();
			var c_idcard = $("input:eq(3)").val();
			var c_password = $("input:eq(4)").val();
			var courier = {
				c_id:courierID,
				c_name:c_name,
				c_phone:c_phone,
				c_idcard:c_idcard,
				c_password:c_password

			};

			$.getJSON("/courier/update.do", courier, function (data) {
				layer.close(windowId);
				layer.msg(data.result);
				if (data.status == 0) {
					$(".header:eq(1),.content:eq(1)").hide();
				}
			});
		});
	})
</script>
</html>
